package com.demo.core.listenerCore;

import com.demo.core.BaseVerifyCore;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class VerifyAspest {

//    public Logger logger = LogInit.getInstance();

    @Pointcut(value = "execution(com.demo.core.BaseVerifyCore com.demo.core.BaseVerifyCore.*(..))")
    public void aspectPointCut(){
    }

    @Around(value = "aspectPointCut()")
    public Object aroundPointCut(ProceedingJoinPoint pJp){
//        logger.info("++++++++++++++++++++++++++++");

        Object result = null;

        try {
            result = pJp.proceed();
        } catch (AssertionError e) {
            e.printStackTrace();
            BaseVerifyCore.errors.add(e);
            BaseVerifyCore.flag = false;
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

//        logger.info("++++++++++++++++++++++++++++");
        return result;
    }

//    @AfterReturning
//    public void afterReturningPointCut(ProceedingJoinPoint pJp) throws Throwable {
//
//    }
}
